module.exports = function($scope, $state, $stateParams,$resource,$modal,toaster){  
	/* 分页
        * ========================================= */
    $scope.maxSize = 5;             //最多显示多少个按钮
    $scope.bigCurrentPage = 1;      //当前页码
    $scope.itemsPerPage = 10         //每页显示几条
    $scope.searchform = {};
    $scope.getlist = function () {
        var para = {
            pageNo:$scope.bigCurrentPage, 
            pageSize:$scope.itemsPerPage,
            'audit_state' : '0'
        };
        para = angular.extend($scope.searchform, para);
        $resource('/api/as/goc/hotelBaseAd/findBaseInfoList ', {}, {}).
        save(para,function(res) {
            console.log(para);
            if (res.errcode !== 0) {
                toaster.error({title:"",body:res.errmsg});
                return;
            }
            console.log(para);
            console.log(res);
            $scope.objs = res.data.results;
            $scope.bigTotalItems = res.data.totalRecord;
        })
    };
     
    $scope.getlist();

    // $scope.create = function() {
    //     $scope.item = {};
    //     $scope.flag = 'create'
    //     var modalInstance = $modal.open({
    //       template: require('../views/addCapitalRule.html'),
    //       controller: 'addCapitalRule',
    //       size: 'lg',
    //       resolve: {
    //         item: function () {
    //             return $scope.item;
    //         },
    //         flag: function () {
    //           return $scope.flag;
    //         },
    //       }
    //     });
    //     modalInstance.result.then(function (showResult) {	
    //         $scope.getlist();
    //     });
    // };
    // $scope.edit = function(item) {
    //     $scope.item = item;
    //     $scope.flag = 'edit'
    //     var modalInstance = $modal.open({
    //       template: require('../views/addCapitalRule.html'),
    //       controller: 'addCapitalRule',
    //       size: 'lg',
    //       resolve: {
    //           item: function () {
    //               return $scope.item;
    //           },
    //           flag: function () {
    //             return $scope.flag;
    //           },
    //       }
    //     });
    //     modalInstance.result.then(function (showResult) {	
    //         $scope.getlist();
    //     });
    // };
    // 删除
    $scope.delete = function(id) {
        if (confirm('确定要删除吗?')) {
            $resource('/api/as/ggc/touristFundsCapitalLawAd/updateDelRule', {}, {}).            
            save({'id':id},function(res) {
                console.log({'id':id});
                if (res.errcode !== 0) {
                    toaster.error({title:"",body:res.errmsg});
                    return;
                } 
                toaster.success({title:"",body:"删除成功"});                
                $scope.getlist();
            })
            return;
        } 
        
    };
    // 发布
    $scope.public = function(id){
      if (confirm('确定要发布吗?')) {
        $resource('/api/as/ggc/touristFundsRuleAd/updateRuleOn', {}, {}).
        save({'id': id},function(res) {
            if (res.errcode !== 0) {
                toaster.error({title:"",body:res.errmsg});
                return;
            }
            console.log(res);
            toaster.success({title:"",body:"发布成功"});
            $scope.getlist();
        })
        return;
      } 
    }
    // 撤回
    $scope.withdraw = function(id){
      if (confirm('确定要撤回吗?')) {
        $resource('/api/as/ggc/touristFundsRuleAd/updateRuleOff', {}, {}).
        save({'id': id},function(res) {
            if (res.errcode !== 0) {
                toaster.error({title:"",body:res.errmsg});
                return;
            }
            console.log(res);
            toaster.success({title:"",body:"撤回成功"});
            $scope.getlist();
        })
        return;
      } 
    }

    // $scope.edit = function(item) {
    //     var modalInstance = $modal.open({
    //     template: require('../views/addsknews.html'),
    //     controller: 'addsknews',
    //     size: 'lg',
    //     resolve: {
    //         item: function () {
    //             return item;
    //         },
    //      }
    //     });
    //     modalInstance.result.then(function (showResult) {	
    //         $scope.getlist();
    //     });
    //     // $state.go('app.addnewsrolling',{'id':id});
    // };


    
    

 

};